#include <gtest/gtest.h>

#include <EngineInterface/Description.h>
#include <EngineInterface/DescriptionEditService.h>
#include <EngineInterface/NumberGenerator.h>
#include <EngineInterface/SimulationFacade.h>
#include <EngineInterface/StatisticsRawData.h>

#include "IntegrationTestFramework.h"

class StatisticsTests : public IntegrationTestFramework
{
public:
    StatisticsTests()
        : IntegrationTestFramework()
    {}

    ~StatisticsTests() = default;
};

TEST_F(StatisticsTests, selfReplicatorWithRepetitionsInGenome)
{
    //auto subGenome = GenomeDescriptionConverterService::get().convertDescriptionToBytes(
    //    GenomeDescription().header(GenomeHeaderDescription().numRepetitions(3)).cells({CellGenomeDescription()}));
    //auto mainGenome = GenomeDescriptionConverterService::get().convertDescriptionToBytes(
    //    GenomeDescription()
    //        .header(GenomeHeaderDescription().numRepetitions(2))
    //        .cells({
    //            CellGenomeDescription().cellType(ConstructorGenomeDescription().genome(subGenome)),
    //            CellGenomeDescription().cellType(ConstructorGenomeDescription().makeSelfCopy()),
    //        }));

    //Description data;
    //data.cells() = {
    //    CellDescription().id(1).cellType(ConstructorDescription()/*.genome(mainGenome)*/),
    //});

    //_simulationFacade->setSimulationData(data);
    //auto statistics = _simulationFacade->getStatisticsRawData();

    //EXPECT_EQ(1, statistics.timeline.timestep.numCells[0]);
    //EXPECT_EQ(1, statistics.timeline.timestep.numSelfReplicators[0]);
    //EXPECT_EQ(10, statistics.timeline.timestep.numGenomeCells[0]);
}

TEST_F(StatisticsTests, selfReplicatorWithInfiniteRepetitionsInGenome)
{
    //auto subGenome = GenomeDescriptionConverterService::get().convertDescriptionToBytes(
    //    GenomeDescription().header(GenomeHeaderDescription().infiniteRepetitions()).cells({CellGenomeDescription()}));
    //auto mainGenome = GenomeDescriptionConverterService::get().convertDescriptionToBytes(
    //    GenomeDescription()
    //        .header(GenomeHeaderDescription().numRepetitions(2))
    //        .cells({
    //            CellGenomeDescription().cellType(ConstructorGenomeDescription().genome(subGenome)),
    //            CellGenomeDescription().cellType(ConstructorGenomeDescription().makeSelfCopy()),
    //        }));

    //Description data;
    //data.cells() = {
    //    CellDescription().id(1).cellType(ConstructorDescription()/*.genome(mainGenome)*/),
    //});

    //_simulationFacade->setSimulationData(data);
    //auto statistics = _simulationFacade->getStatisticsRawData();

    //EXPECT_EQ(1, statistics.timeline.timestep.numCells[0]);
    //EXPECT_EQ(1, statistics.timeline.timestep.numSelfReplicators[0]);
    //EXPECT_EQ(6, statistics.timeline.timestep.numGenomeCells[0]);
}

TEST_F(StatisticsTests, nonSelfReplicatorWithRepetitionsInGenome)
{
    //auto subGenome = GenomeDescriptionConverterService::get().convertDescriptionToBytes(
    //    GenomeDescription().header(GenomeHeaderDescription().numRepetitions(3)).cells({CellGenomeDescription()}));
    //auto mainGenome = GenomeDescriptionConverterService::get().convertDescriptionToBytes(
    //    GenomeDescription()
    //        .header(GenomeHeaderDescription().numRepetitions(2))
    //        .cells({
    //            CellGenomeDescription().cellType(ConstructorGenomeDescription().genome(subGenome)),
    //        }));

    //Description data;
    //data.cells() = {
    //    CellDescription().id(1).cellType(ConstructorDescription()/*.genome(mainGenome)*/),
    //});

    //_simulationFacade->setSimulationData(data);
    //auto statistics = _simulationFacade->getStatisticsRawData();

    //EXPECT_EQ(1, statistics.timeline.timestep.numCells[0]);
    //EXPECT_EQ(0, statistics.timeline.timestep.numSelfReplicators[0]);
    //EXPECT_EQ(00, statistics.timeline.timestep.numGenomeCells[0]);
}
